# -*- coding: utf-8 -*-
import getopt
import sys


def usage():
    print """%s [-h -l] -c cfg -d dest_dir
    -h --help: show help
    -c --cfg: specify configuration file
    -d --directory: specify directory where templates file will be instantiated
    -l --list: only list template file""" % sys.argv[0]


try:
    opts, args = getopt.getopt(sys.argv[1:], "hd:lc:", ['help', 'directory=', 'list', "cfg="])
except getopt.GetoptError, err:
    print str(err)
    usage()
    sys.exit(1)

print type(opts)

for m in opts:
    print m, type(m)

for o, a in opts:
    print o  # 取到-h
    print a  # 取到值
